﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Practices.ServiceLocation;
using Sok.Munkae.ApplicationServices;

namespace Sok.Munkae.Web
{
    public partial class Login : System.Web.UI.Page
    {
        private IAuthenticationService authenticationService;

        protected void Page_Load(object sender, EventArgs e)
        {
            authenticationService = ServiceLocator.Current.GetInstance<IAuthenticationService>();
        }

        protected void Login_Button_Click(object sender, EventArgs e)
        {
            if(authenticationService.Authenticate(UserNameTextBox.Text, PasswordTextBox.Text, false))
            {
               //normally you'd deal with returnUrl and rememberMe here, but eh...DEMO!
               Response.Redirect("/default.aspx"); 
            }
            else
            {
                InvalidLogin.Text = "Invalid UserName or Password. Try again, Sok Munkae!";
            }
        }

    }
}
